class Solution {
    public int maxProduct(int[] nums) {
        int len = nums.length ;
        long[] f = new long[len] ;
        long[] g = new long[len] ;
        long max = nums[0] ;
        f[0] = g[0] = nums[0] ;
        for(int i=1 ; i < len ; i ++){
            f[i] = Math.max(Math.max(f[i-1]*nums[i] , nums[i]) , g[i-1]*nums[i]) ;
            g[i] =Math.min( Math.min(g[i-1] * nums[i] , nums[i]), f[i-1] * nums[i]);
            if(Math.log10(Math.abs(g[i])) > 10) {
                g[i] = 1;
            }
            max = Math.max(f[i] , max) ;
        }
        return (int) max ;
    }
}